import re
import sys

# 检查输入参数
if len(sys.argv) < 2:
    print("请提供数据文件路径作为参数")
    sys.exit(1)

# 获取数据文件路径
file_path = sys.argv[1]

# 打开数据文件
with open(file_path, 'r') as file:
    data = file.read()

# 使用正则表达式提取任务的性能和时间
pattern = r'\[Task\s+(\d+)\s*/\s*\d+\]\s+Current/Best:\s+\d+\.\d+/(?P<performance>\d+\.\d+)\s+GFLOPS\s+\|\s+Progress:\s+\(\d+/\d+\)\s+\|\s+(?P<time>\d+\.\d+)\s+s'
matches = re.findall(pattern, data)

# 创建任务字典，以任务编号为键，性能和时间为值
tasks = {}
for match in matches:
    task_number = int(match[0])
    performance = float(match[1])
    time = float(match[2])
    tasks[task_number] = {'performance': performance, 'time': time}

# 按任务编号升序排列任务字典
sorted_tasks = sorted(tasks.items(), key=lambda x: x[0])

# 打印每个任务的性能和时间
for task_number, task_data in sorted_tasks:
    print(f'Task {task_number}: Performance - {task_data["performance"]} GFLOPS, Time - {task_data["time"]} s')

